package com.foreknow.oop1;

public class TestStudent {
  public static void main(String[] args) {
    Student st1 = new Student();
    st1.setId(101);
    st1.setName("张三");
    st1.setScore(90);

    Student st2 = new Student();
    st2.setId(102);
    st2.setName("李四");
    st2.setScore(80);

    Student st3 = new Student();
    st3.setId(103);
    st3.setName("王五");
    st3.setScore(100);

    //对象数组：数组中只能存对象
    Student[] stu = new Student[3];
    //如何将对象保存到数组中
    stu[0] = st1;//将st1这个对象保存到stu数组中
    stu[1] = st2;
    stu[2] = st3;

    //如何获取到数组中的Student对象
    for (int i = 0;i<stu.length;i++){
      //从数组中获取到对象
//      Student s = stu[i];//获取到数组中的某一个元素并赋值给s变量
//      System.out.println(s.getId()+"--"+s.getName()+"--"+s.getScore());
      System.out.println(stu[i].getId()+"--"+stu[i].getName()+"--"+stu[i].getScore());//输出的是内存地址
    }

  }
}
